<template>
    <div class="mui-numbox" data-numbox-min='0' style="height:25px" >
        <button class="mui-btn mui-btn-numbox-minus" type="button" @click="changed">-</button>
        <input id="test" class="mui-input-numbox" type="number" :value="initcount" ref="numbox"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button" @click="changed">+</button>
    </div>
</template>
<script>
import mui from "../../../lib/mui/js/mui.js"
import { mapMutations } from 'vuex'
export default {
    data(){
        return {};
    },
    mounted(){
        //当数组挂载到页面中之后，去初始化数字框
        mui('.mui-numbox').numbox();   
        //往父组件GoodsInfo传值
    },
    methods:{
        changed(){
            //const val = mui('.mui-numbox').numbox().getValue();
            const val =parseInt(this.$refs.numbox.value);
            console.log(val)
            this.updateGoodsCount({id:this.id,count:val})
        },
        ...mapMutations(['updateGoodsCount'])
    },
    props:['initcount','id'],
}
</script>
<style lang="scss" scoped>

</style>